/**
 * caicongyang.com Inc.
 * Copyright (c) 2004-2017 All Rights Reserved.
 */
package com.caicongyang.design.clone;

/**
 * 深复制测试：深拷贝违反了面向对象封装的规则
 * @author caicongyang1
 * @version id: CloneClientTest, v 0.1 17/5/13 下午8:52 caicongyang1 Exp $$
 */
public class CloneClientTest {
    public static void main(String[] args) throws Exception {
        Professor p = new Professor("Tom", "数据科学");
        Student s1 = new Student("zhangsan", 18, p);
        Student s2 = (Student) s1.clone();
        s2.getProfessor().setName("Json");
        s2.getProfessor().setSbuject("数据科学");
        System.out.println("name=" + s1.getProfessor().getName() + "," + "subject=" + s1.getProfessor().getSbuject());//学生1的教授
        System.out.println("name=" + s2.getProfessor().getName() + "," + "subject=" + s2.getProfessor().getSbuject());//学生1的教授

    }
}
